<!--
 * @Author: chen jiao
 * @Date: 2021-07-07 14:00:43
 * @LastEditTime: 2021-08-13 10:49:32
 * @LastEditors: Please set LastEditors
 * @Description: 会员标签
 * @FilePath: \ebc-admin\src\views\member\SetTag.vue
-->
<template>
  <div class="setTag">
    <tab-list
      ref="list"
      :searchs="searchs"
      :list-hedar="listHedar"
      :params="params"
      other-show
      :api-function="apiFunction"
      @add-list="openEditBox()"
      @init-params="initParams"
     >
      <span slot="tagType" slot-scope="scope">
        {{ scope.value.tagType === '0' ? "自动标签" : "手动标签"  }}
      </span>
      <span slot="expire" slot-scope="scope">
        {{ scope.value.expire == 0 ? "永久" : scope.value.expire  }}
      </span>
      <span slot="tagStatus" slot-scope="scope">
        {{ 
          scope.value.tagStatus === '0' ? '未生成':
          scope.value.tagStatus === '1' ? '生成中':
          scope.value.tagStatus === '2' ? '已生成': ''
         }}
      </span>
      <template slot="operate" slot-scope="scope">
        <el-button type="text" size="small" @click="checkList(scope.value)">查看会员</el-button>
        <el-button type="text" size="small" @click="editHandle(scope.value)">编辑</el-button>
        <el-button type="text" size="small" @click="deleteBtn(scope.value)">删除</el-button> 
      </template>
    </tab-list>
  </div>
</template>

<script>
// 组件
import tabList from '@/components/admin/tab-list.vue'
// 数据封装
import {searchs, listHedar } from './config/setTag.config.js'
// 接口
import { memberTagsList ,tagDel, getMember } from '@/api/member.js'
// 公共方法
import { openMessageBox ,asyncApiFun } from '@/utils/utils.js'

export default {
  components: { tabList },
      name:'setTag',
      data() {
        return {
          params:{},
          searchs,
          listHedar,
          otherShow:true,
          apiFunction:memberTagsList,
          tagId:'', //预设参数
        }
      },
      methods:{
      //添加
      openEditBox(){
        this.$router.push({ path:'/setTag/label' })
      }, 
      //查看会员
        checkList({  tagId }){
          this.$router.push({
               path:'/member/list',
               query:{
                 tagId
                 } 
               })
            
        },
      // 编辑
        editHandle({ tagId }){
          this.$router.push({ path: '/setTag/label?id='+tagId })
        },
      // 删除弹框
        deleteBtn({tagId}) {
          openMessageBox({
            content: '删除数据后，将不可恢复，是否确认？',
            title: '删除数据',
            confirm: '确认',
            cancel: '取消'
          }, async boole => {
            if (boole) {
              // 点击确认
              const [res] = await asyncApiFun(tagDel, tagId)
               if (res) {
                 console.log(res)
                 this.$refs.list.getList()
               }
            } else {
              // 点击取消
             
            }
          })
        },
      
      // 初始化列表请求参数
      initParams(param) {
        this.params = param
        }
      }
  }
</script>

<style lang="scss" scoped>

</style>